<template>
  <el-dialog
    v-model="visible"
    title="新增角色"
    width="45%"
    :before-close="handleClose"
  >
    <el-form  :model="form" label-width="120px" style="width:88%;" >
      <el-form-item label="编号">
        <el-input v-model="form.ro_id"></el-input>
      </el-form-item>
      <el-form-item label="名称">
        <el-input v-model="form.ro_name"></el-input>
      </el-form-item>
      <el-form-item label="备注">
        <el-input v-model="form.ro_remark" type="textarea" :rows="3"></el-input>
      </el-form-item>
    </el-form>

    <template #footer>
      <span class="dialog-footer">
        <el-button @click="visible = false">关闭</el-button>
        <el-button type="primary" @click="exec">确定</el-button>
      </span>
    </template>
  </el-dialog>
</template>

<script setup >
import { reactive, ref } from "vue";
import { tip, get, post, put, del, ddo } from "@/common";

const visible = ref(false);
const open = () => {
  visible.value = true;
};
const handleClose = (done) => {
  done();
};

const form = reactive({
  ro_id: "",
  ro_name: "",
  ro_remark:""
});

const emit = defineEmits(["ok"]); 
const exec = ()=>{
    post('/security/role',form,{title:'提示',message:'您确定提交新角色信息吗？'}).then(result=>{
        emit('ok');
        visible.value = false;
        for(let prop in form){
            form[prop] = '';
        }
        console.log(form);
        tip.success('新增成功！');
    });
};

defineExpose({ open });
</script>

<style>
</style>